<?php
/**
 * ebiz front
 * 
 * Init file
 *  
 * @author allen
 *  
 */

require_once 'core/db/DBUtil.class.php';
require_once '../conf/config.php';
require_once '../app/models/ConfigDao.php';
require_once '../app/models/EmailDao.php';
require_once '../app/models/ColorDao.php';

function Init(){
    initDebug();
    initDb();
    initLocale();
    initCommonData();
    initConfig();
    initSSLProtocol();
    initColor();
}

function initDb(){
	global $dbUtil;
    $dbUtil = new DBUtil();
}

function initLocale(){
	$language = LANGUAGE;
	$country = COUNTRY;
	global $local;
	$local = "data/".$language.'_'.$country;
}

function initCommonData(){
    require_once "../" . $GLOBALS["local"] . "/"."common.php";
}

function initConfig(){
	//put the value in array 
	global $config;
	$config = array();
	$configDao = new ConfigDao($GLOBALS['dbUtil']);
	$results = $configDao->getAllConf();
	foreach($results as $result){
		$config[$result['conf_key']] = $result['conf_value'];
	}
}

function initDebug(){
	//define the status of the debug info, 1 is ON, 0 is OFF, -1 is init
	global $debug;
	$debug = 0;
}

function initSSLProtocol(){
	//define the default $SSLProtocol is http, use in all https page to set the href path for testing
	global $SSLProtocol;
	$SSLProtocol = "http";
}

function initColor(){
    global $color;
    $color = array();
    $colorDao = new ColorDao($GLOBALS['dbUtil']);
    $results = $colorDao->getAllColor();
    foreach($results as $result){
        $color[$result['value']] = $result['color_value'];
    }
}


